package com.hkyp.ss.course.provider.model;


import com.hkyp.ss.course.provider.model.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * @Description: 用户信息表
 * @Author:
 * @CreateDate: 2018/7/18 14:25
 */
@Data
@Entity
@EqualsAndHashCode(callSuper=true)
@DynamicUpdate
@DynamicInsert
@Table(
        indexes = {
                @Index(columnList = "email",name = "emailIndex"),
                //常做查询条件的列加索引
                @Index(columnList = "status",name = "statusIndex"),
        }
)
public class User extends BaseEntity {

    private static final long serialVersionUID = 201L;


    /**
     * open id
     * 用户唯一标识(微信)
     */
    @Column(name = "open_id")
    private String openId;

    /**
     * 用户昵称
     * 字段长度15
     * 需求限制长度在2-14字符之间
     */
    @Column(name = "nick_name", length = 15)
    private String nickName;

    /**
     * 用户性别
     *  null，未设置
     *  1，男
     *  2，女
     */
    @Column(name = "gender")
    private Integer gender;


    /**
     * 头像
     * 存储头像上传到OSS后返回的url
     */
    @Column(name = "avatar", length = 500)
    private String avatar;

    /**
     * 邮箱
     * 字段长度20
     * 需进行格式校验
     */
    @Column(name = "email", length = 20)
    private String email;

    /**
     * 手机号
     * 字段长度20
     * 需进行格式校验
     */
    @Column(name = "phone", length = 20)
    private String phone;


    /**
     * 密码
     */
    @Column(length = 40)
    private String password;


    /**
     *  学历
     *
     *  30，高中
     *  40，大专  50.本科  60.研究生 70.博士
     */
    @Column(name = "diplomas", columnDefinition = "tinyint")
    private Integer diplomas;

    /**
     *  职业
     *  限制40字
     */
    @Column(length = 50)
    private String occupation;

    /**
     * 粉丝数
     */
    private Integer fansNum = 0;


    /**
     * 用户状态
     * 默认值为1
     * 1：冻结；0：正常，2/3.邮箱未激活  10 逻辑删除
     */
    @Column(name = "status", columnDefinition = "tinyint")
    private Integer status = 0;


}


